# -*- coding: utf-8 -*-
"""
summary:
    首页文章模板
author:
    Jason Lee <huacnlee@gmail.com>
"""
from django.template import Library,defaultfilters
from utils.helper import view
from settings import *

register = Library()
__FILTER_NAME_PREFIX = "blog_componsent_comment_"
__TEMPLATE_ROOT = "blog/components/comment/%s"

def body(comments):
    """
    summary:
        评论项
    """    
    html = ""
    
    if not comments:
        return html
    
    i = 1
    for item in comments:
        data = {
                'comment' : item,
                'floor' : i,
                }
        html = html + defaultfilters.safe(view.out_html(__TEMPLATE_ROOT % ('body.html'),data))
        i = i + 1
        
    return defaultfilters.safe(html)


register.filter('%sbody' % __FILTER_NAME_PREFIX, body)